/*
 * @Author: mikey.zhaopeng 
 * @Date: 2018-12-13 22:53:09 
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2018-12-14 00:24:56
 */
import 'package:flutter/material.dart';
import '../constants.dart' show AppColors;

class FullWidthIconButton extends StatelessWidget{
  static const ICON_SIZE =24.0;
  static const HORIZONTAL_PADDING = 20.0;
  static const VERTICAL_PADDING = 12.0;

  FullWidthIconButton({
    @required this.title,
    @required this.iconPath,
    @required this.onPressed,
    this.showDivider:false
  }):assert(iconPath != null),assert(title !=null),assert(onPressed != null);

  final String title;
  final String iconPath;
  final VoidCallback onPressed;
  final bool showDivider;
  @override
  Widget build(BuildContext context){
    final Widget pureButton = Container(
      padding: const EdgeInsets.only(
      ),
      child:Row(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Image.asset(iconPath,width: ICON_SIZE,height: ICON_SIZE,),
          SizedBox(width: HORIZONTAL_PADDING),
          Text(title)
        ],
      )
    ); 
    final Widget borderButton = Container(
      padding: const EdgeInsets.only(
        bottom: VERTICAL_PADDING
      ),
      child: pureButton,
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            color: Color(AppColors.BackgroundColor),
            width: 1.0
          )
        )
      ),
    );

    return FlatButton(
      color: Colors.white,
      padding: EdgeInsets.only(
        left:HORIZONTAL_PADDING,
        right:HORIZONTAL_PADDING,
        top: VERTICAL_PADDING,
        bottom: showDivider?0.0: VERTICAL_PADDING,
      ),
      onPressed:onPressed,
      child: showDivider? borderButton:pureButton,
    );
  }
}